﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/admincp.Master" AutoEventWireup="true"
    CodeBehind="ListOrders.aspx.cs" Inherits="SES.CMS.AdminCP.ListOrders" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <h1 class="title">
                Danh sách đơn hàng</h1>
            <div class="search">
                <fieldset class="fieldset">
                    <legend>Lọc hiển thị</legend>
                    <table width="100%">
                        <tr>
                            <td style="width: 282px">
                                <label>
                                    Sắp xếp theo</label>
                                <asp:DropDownList ID="dropSort" runat="server" CssClass="dropDown" AutoPostBack="True" 
                                Width="150px" OnSelectedIndexChanged="dropSort_SelectedIndexChanged">
                                    <asp:ListItem Text="Mới nhất" Value="1" Selected="True" />
                                    <asp:ListItem Text="Cũ nhất" Value="2" />
                                </asp:DropDownList>
                                
                            </td>
                            <td align="left">
                                <label>
                                    Tình trạng</label>
                                <asp:DropDownList ID="dropIsView" runat="server" CssClass="dropDown" Width="100px"
                                    AutoPostBack="True" OnSelectedIndexChanged="dropIsView_SelectedIndexChanged">
                                    <asp:ListItem Value="0" Text="Tất cả" Selected="True" />
                                    <asp:ListItem Value="1" Text="Chờ xử lý" />
                                    <asp:ListItem Value="2" Text="Đã hoàn thành" />
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
            <div id="gridview">
                <asp:GridView ID="gridView" runat="server" CssClass="tstyle1" Width="100%" AutoGenerateColumns="False"
                    CellPadding="3" EnableModelValidation="True" GridLines="None" AllowPaging="True"
                    BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1"
                    PageSize="10" OnRowDataBound="gridView_RowDataBound" OnPageIndexChanging="gridView_PageIndexChanging"
                    OnRowDeleting="gridView_RowDeleting" EmptyDataText="Dữ liệu trống !" OnRowCommand="gridView_RowCommand">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <%# Container.DataItemIndex+1 %>
                            </ItemTemplate>
                            <ItemStyle Width="5px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Chọn">
                            <ItemTemplate>
                                <asp:CheckBox ID="checkBox" runat="server" />
                            </ItemTemplate>
                            <ItemStyle Width="2px" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="Id" HeaderText="ID">
                            <ItemStyle Width="10px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CustomerId" HeaderText="Khách hàng">
                            <ItemStyle Width="30px" />
                        </asp:BoundField>
                         
                        <asp:TemplateField HeaderText="Ngày đặt">
                            <ItemTemplate>
                                <asp:Label ID="lblDateStart" runat="server" Text='<%#Eval("DateOfStart", "{0:dd/MM/yyyy}")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="20px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Ngày yêu cầu">
                            <ItemTemplate>
                                <asp:Label ID="lblDateFisnish" runat="server" Text='<%#Eval("DateOfFisnish","{0:dd/MM/yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="20px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tình trạng">
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" runat="server" Text='<%# ((Boolean)Eval("Status"))==true ? "Đã hoàn thành" : "Chờ xử lý" %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="30px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:ButtonField CommandName="Xem" HeaderText="Xem">
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle ForeColor="#000099" CssClass="btnView" Width="10px" 
                            HorizontalAlign="Center" />
                        </asp:ButtonField>
                        <asp:TemplateField HeaderText="Xóa">
                            <ItemTemplate>
                                <asp:LinkButton ID="linkDelete" runat="server" CausesValidation="false" Text="" CssClass="btnDelete"
                                    CommandName="Delete" OnClientClick="return confirm('Bạn có chắc chắn muốn xóa ?')"> </asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="10px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                    <ProgressTemplate>
                        <img src="../../Images/ajax-loader.gif" alt="Loadding" style="position: absolute;
                            top: 50%; left: 50%; z-index: 1000" />
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
            <div>
                <table style="width: 100%">
                    <tr>
                        <td align="left" valign="top">
                            <asp:LinkButton ID="linkCheckAll" runat="server" Text="Chọn tất cả" CssClass="button-gg-green"
                                OnClick="linkCheckAll_Click" />&nbsp; &nbsp; &nbsp;
                            <asp:LinkButton ID="linkUnCheckAll" runat="server" Text="Bỏ chọn" CssClass="button-gg-green"
                                OnClick="linkUnCheckAll_Click" />
                        </td>
                        <td align="right">
                            <asp:Button runat="server" ID="btnXoaChon" Text="Xóa chọn" CssClass="button-gg-green"
                                OnClientClick="return confirm('Bạn có chắc chắn muốn xóa ?')" OnClick="btnXoaChon_Click" />
                        </td>
                    </tr>
                </table>
            </div>
            <div style="margin: 10px 0px">
                <label>
                    Số dòng hiển thị trên 1 trang :
                </label>
                <asp:DropDownList runat="server" ID="dropPageSize" CssClass="dropdown" AutoPostBack="true"
                    OnSelectedIndexChanged="dropCountRow_SelectedIndexChanged">
                    <asp:ListItem Text=" 10 " Value="10" Selected="True" />
                    <asp:ListItem Text=" 20 " Value="20" />
                    <asp:ListItem Text=" 30 " Value="30" />
                    <asp:ListItem Text=" 50 " Value="50" />
                    <asp:ListItem Text=" 100 " Value="100" />
                </asp:DropDownList>
            </div>
            <fieldset id="details"  visible="false" class="fieldset" runat="server">
                    <legend>Chi tiết đơn hàng</legend>
            <div  style="margin-top: 10px;padding-left: 150px;">
                <table style="font-size: 12px;" width="100%" cellspacing="0">
                    <tr>
                        <td style="width: 100px; height: 30px;">
                            Họ tên :
                        </td>
                        <td>
                            <asp:Literal ID="ltName" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 30px;">
                            Email :
                        </td>
                        <td>
                            <asp:Literal ID="ltEmail" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 30px;">
                            Phone :
                        </td>
                        <td>
                            <asp:Literal ID="ltPhone" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 30px; padding-bottom: 5px;">
                            Địa chỉ giao hàng :
                        </td>
                        <td>
                            <asp:Literal ID="ltAddress" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 30px; padding-bottom: 5px;">
                            Ngày đặt hàng:
                        </td>
                        <td>
                            <asp:Literal ID="ltNgaydat" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px; height: 30px; padding-bottom: 5px;">
                            Ngày giao hàng:
                        </td>
                        <td>
                            <asp:Literal ID="ltNgaygiao" runat="server" />
                        </td>
                    </tr>
                </table>
                <asp:GridView ID="listDetail" runat="server" CssClass="tstyle1" Width="85%" AutoGenerateColumns="False"
                    CellPadding="3" EnableModelValidation="True" GridLines="None" AllowPaging="True"
                    BackColor="White" BorderColor="White" BorderStyle="Ridge" 
                    BorderWidth="2px" CellSpacing="1"
                    PageSize="8" EmptyDataText="Dữ liệu trống !" 
                    onrowdatabound="listDetail_RowDataBound" >
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <%# Container.DataItemIndex+1 %>
                            </ItemTemplate>
                            <ItemStyle Width="5px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Mã SP">
                            <ItemTemplate>
                                <asp:Label ID="lblCode" runat="server" Text='<%#Eval("ProductCode")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="15px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tên SP">
                            <ItemTemplate>
                                <asp:Label ID="lblName" runat="server" Text='<%#Eval("ProductTitle")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="60px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Số lượng">
                            <ItemTemplate>
                                <asp:Label ID="lblQty" runat="server" Text='<%#Eval("Qty")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="10px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Đơn giá">
                            <ItemTemplate>
                                <asp:Label ID="lblPrice" runat="server" Text='<%#Eval("Price","{0:0,0 VNĐ}")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="15px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thành tiền">
                            <ItemTemplate>
                                <asp:Label ID="lblPrice" runat="server" Text='<%#Eval("ThanhTien","{0:0,0 VNĐ}")%>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle Width="20px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <p>Tổng tiền: <%=Total %></p>
                 <asp:LinkButton ID="btnXuLy" runat="server" Text="Xử lý" CssClass="button-gg-green"
                                OnClick="btnXuLy_Click" />
                                <asp:LinkButton ID="btnBoqua" runat="server" Text="Bỏ qua" CssClass="button-gg-green"
                                OnClick="btnBoqua_Click" CausesValidation="False" />
            </div>
          
            </fieldset>
            <div style="margin-top: 10px">
                <asp:Literal ID="lbThongBao" runat="server" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
